const Sequelize = require('sequelize');
const dotenv = require('dotenv');

dotenv.config();

// 创建Sequelize实例
const sequelize = new Sequelize(
  process.env.DB_NAME || 'npm_explore',
  process.env.DB_USER || 'fengjiaheng',
  process.env.DB_PASSWORD || 'jiaheng969',
  {
    host: process.env.DB_HOST || 'localhost',
    port: process.env.DB_PORT || 3306,
    dialect: 'mysql',
    pool: {
      max: 10,
      min: 0,
      acquire: 30000,
      idle: 10000
    },
    define: {
      timestamps: true,
      underscored: true
    },
    logging: process.env.NODE_ENV === 'development'
  }
);

module.exports = sequelize;